home *** CD-ROM | disk | FTP | other *** search
- Path: news.netins.net!trg1
- From: hhowe@trgnet.com (Harold Howe)
- Newsgroups: comp.lang.c++
- Subject: Is this a memory leak?
- Date: Wed, 03 Apr 96 22:39:41 GMT
- Organization: Technology Resource Group
- Message-ID: <4jv214$gv7@insosf1.netins.net>
- NNTP-Posting-Host: desm-21-08.dialup.netins.net
- X-Newsreader: News Xpress Version 1.0 Beta #3
-
- Could someone please tell me if this code leaks memory
-
- class BuriedClass
- {
- ...
- }
-
- class TopClass
- {
- private
- BuriedClass *bury;
- public:
- TopClass::TopClass() { bury = new BuriedClass();}
- shutDown { bury = 0;}
- ~TopClass { delete bury}
- }
-
- int main(void)
- {
- TopClass *top = new TopClass();
- top->shutDown();
- delete top;
- return 0;
- }
-
- Is the memory that was alloced for the buried class lost? If not please
- describe how it was freed. Does zeroing the pointer free the memory? The
- delete is a waste of time on a zeroed pointer, isn't it.
-
- All help would be greatly appreciated. For what its worth, I am on a PC,
- using BC 45 with Turbovision, and this question relates to turbovisions
- shutdown function, which does this zeroing out busines that I don't
- understand.
-
- Thanks
- Harold Howe
- hhowe@trgnet.com
-
-